package 使数组中所有元素都等于零;

import java.util.Arrays;

/**
 * @Program:IntelliJ IDEA
 * @description:
 * @author:香蕉你个啵娜娜 l.h-p@qq.com
 * @create:2023-02-24 08:46
 **/

public class Solution {
    public static int minimumOperations(int[] nums) {
        Arrays.sort(nums);
        int flag = 0;
        int min = 0;
        int con = 1;
        while (flag > 0) {
            flag = 0;
            for (int i = 0; i < nums.length; i++) {
                flag = nums[i] + flag;
                if (nums[i] > 0 && nums[i] < min) {
                    min = nums[i];
                }
                nums[i] -= min;
            }
            con++;
            Arrays.sort(nums);
        }
        return con;
    }

    public static void main(String[] args) {
        int[] num = {1, 5, 0, 3, 5};
        System.out.println(minimumOperations(num));
    }
}
